package com.irs.irsforum.entity;


import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * @author Liyihui
 * @Date: 2020/3/22
 * @Time: 3:09
 */
@Data
@Component
public class Resources {

    private static Integer PAGE_SIZE;
    private static String TEACHER_ROLE = "teacher";
    private static String STUDENT_ROLE = "student";
    private static Long MSG_EXIST_MINUTES;
    private static Integer INDEX_RECOMMEND_SIZE;
    private static Long CACHE_TIME;
    private static TimeUnit REDIS_TIME_TYPE;
    private static Integer MESSAGE_RECOMMEND_NUMBER ;
    private static String PRIVATESTRINGKEY;
    private static String IRSINDEXPAGE;

    @Value("${PAGESIZE}")
    public void setPageSize(Integer pageSize) {
        PAGE_SIZE = pageSize;
    }

    @Value("${MSG_EXIST_MINUTES}")
    public void setMsgExistMinutes(Long msgExistMinutes) {
        MSG_EXIST_MINUTES = msgExistMinutes;
    }

    @Value("${CACHE_TIME}")
    public void setCacheTime(Long cacheTime) {
        CACHE_TIME = cacheTime;
    }

    @Value("${INDEX_RECOMMEND_SIZE}")
    public void setIndexRecommendSize(Integer indexRecommendSize) {
        INDEX_RECOMMEND_SIZE = indexRecommendSize;
    }

    @Value("${MESSAGE_RECOMMEND_NUMBER}")
    public void setMessageRecommendNumber(Integer messageRecommendNumber) {
        MESSAGE_RECOMMEND_NUMBER = messageRecommendNumber;
    }

    @Value("${PRIVATEKEYSTRING}")
    public void setPrivateKeyString(String privateKeyString) {
        PRIVATESTRINGKEY = privateKeyString;
    }

    @Value("${REDIS_TIME_TYPE}")
    public void setRedisTimeType(String redisTimeType) {
        if ("MIN".equals(redisTimeType)) {
            REDIS_TIME_TYPE =  TimeUnit.MINUTES;
        } else if ("SEC".equals(redisTimeType)) {
            REDIS_TIME_TYPE = TimeUnit.SECONDS;
        }
        REDIS_TIME_TYPE = TimeUnit.HOURS;
    }

    @Value("${IRSINDEXPAGE}")
    public void setIRSINDEXPAGE(String irsIndexPage) {
        IRSINDEXPAGE = irsIndexPage;
    }

    public static Integer getPageSize() {
        return PAGE_SIZE;
    }

    public static String getTeacherRole() {
        return TEACHER_ROLE;
    }

    public static String getStudentRole() {
        return STUDENT_ROLE;
    }

    public static Long getMsgExistMinutes() {
        return MSG_EXIST_MINUTES;
    }

    public static Integer getIndexRecommendSize() {
        return INDEX_RECOMMEND_SIZE;
    }

    public static Long getCacheTime() {
        return CACHE_TIME;
    }

    public static TimeUnit getRedisTimeType() {
        return REDIS_TIME_TYPE;
    }

    public static Integer getMessageRecommendNumber() {
        return MESSAGE_RECOMMEND_NUMBER;
    }

    public static String getPrivateKeyString() {
        return PRIVATESTRINGKEY;
    }

    public static String getIRSINDEXPAGE() {
        return IRSINDEXPAGE;
    }
}


